/**
 * @file
 * @brief Linux specific header for fsnotify
 */

#ifndef _FSNOTIFY_DEF_H
#define _FSNOTIFY_DEF_H

#include <types.h>

#include <sys/inotify.h>
#include <glib.h>


typedef int watch_desc_t;

static inline void
watch_desc_init(watch_desc_t *wd)
{
    *wd = -1;
}

static inline bool
watch_desc_is_valid(watch_desc_t wd)
{
    return wd >= 0;
}

struct fsnotify_desc {
    int fd;
    GHashTable *wd_map;
    GString *buf; /**< Path temporary buffer */
};

#define FSNOTIFY_DESC_STATIC_INITIALIZER {-1, NULL, NULL}


//#define FS_ACCESS           IN_ACCESS
#define FS_MODIFY           IN_MODIFY
//#define FS_ATTRIB           IN_ATTRIB
//#define FS_CLOSE_WRITE      IN_CLOSE_WRITE
//#define FS_CLOSE_NOWRITE    IN_CLOSE_NOWRITE
//#define FS_CLOSE            (FS_CLOSE_WRITE | FS_CLOSE_NOWRITE)
//#define FS_OPEN             IN_OPEN
#define FS_MOVED_FROM       IN_MOVED_FROM
#define FS_MOVED_TO         IN_MOVED_TO
#define FS_MOVE             (FS_MOVED_FROM | FS_MOVED_TO)
#define FS_CREATE           IN_CREATE
#define FS_DELETE           IN_DELETE
//#define FS_DELETE_SELF      IN_DELETE_SELF
//#define FS_MOVE_SELF        IN_MOVE_SELF

#define FS_ISDIR            IN_ISDIR


#endif /* ! _FSNOTIFY_DEF_H */
